package com.example.springbooteasycode.bootsocket;

import com.example.springbooteasycode.aop.LogA;
import com.example.springbooteasycode.aop.LogB;
import org.springframework.stereotype.Component;

@Component // 被 Spring 管理，确保 AOP 能拦截
public class KoalCommandParser {

    // 标记 @LogA 注解，触发切面逻辑
    @LogA
    public byte[] parseCommand(byte[] command) {
        System.out.println("解析命令：" + new String(command));
        // 模拟处理：返回响应
        return "处理完成".getBytes();
    }

    // 在方法上使用带参数的@LogA注解
    @LogB(
            commandModule = "加密模块",
            specificCommand = "SM4_ENCRYPT",
            encryptMachineIp = "192.168.1.100",
            encryptMachinePort = "8000",
            commandDesc = "SM4算法加密"
    )
    public byte[] parseEncryptionCommand(byte[] command) {
        System.out.println("解析命令：" + new String(command));
        // 模拟加密处理
        return "加密成功".getBytes();
    }

    // 另一个带不同参数的示例方法
    @LogB(
            commandModule = "解密模块",
            specificCommand = "SM4_DECRYPT",
            encryptMachineIp = "192.168.1.101",
            encryptMachinePort = "8001",
            commandDesc = "SM4算法解密"
    )
    public byte[] parseDecryptCommand(byte[] command) {
        System.out.println("解析解密命令：" + new String(command));
        // 模拟解密处理
        return "解密成功".getBytes();
    }
}
